import React,{Component} from  'react'
import ReactDOM from 'react-dom'
import './index.css'
class Father extends Component {
    state={
        current: 0
    }
    addclass (idx) {
        this.setState({current:idx})
    }
    render() {
        return (
            <ul>
               {new Array(5).fill().map(( item,index)=><li idx={index} className={this.state.current === index ? "bgc" : null} onClick={this.addclass.bind(this,index)} key={index}></li>)}
            </ul>
        )
    }
}
ReactDOM.render(<Father />,document.getElementById('root'))
